package com.jt.provider.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope //假如希望配置中心内容发生变化,要对类中属性进行重新初始化,可使用此注解对类进行描述
@Slf4j
@RestController
public class ProviderLogController {
public ProviderLogController(){
    System.out.println("==ProviderLogController==");
}
    @GetMapping("/provider/log/doLog01")
    public String doLog01(){
        System.out.println("==doLog01==");
       log.trace("==trace==");
       log.debug("==debug==");
       log.info("==info==");//springboot工程默认日志级别
       log.warn("==warn==");
       log.error("==error==");
        return "test log level";
    }

    //定义一个日志级别数据,用于存储从配置文件或配置中心读取的数据
    @Value("${logging.level.com.jt:error}")
    private String logLevel;

    @GetMapping("/provider/log/doLog02")
    public String doLog02(){
        log.info("log level is  {}",logLevel);
        return  "log level  is "+logLevel;
    }



}
